<?php

require_once "core_local.php";
require_once SITE_ROOT_PATH."ld/_lib/classes/class.tree.php";
/*
$h = fopen("locations_low.csv", "r");
if (!$h) {
    return FALSE;
}
$sqltpl = 'insert into supplier_locations_low (country_id,country,region_id,region,resort_id,resort) values (%d,"%s",%d,"%s",%d,"%s");';
while (($f=fgetcsv($h, 100)) !== FALSE) {
    $f = in($f);
    $sql = sprintf($sqltpl, $f[0],$f[1],$f[2],$f[3],$f[4],$f[5]);
    $result = mysql_query($sql) or die (mysql_error());
    print_r($result);
}
*/
$l1 = array(
    11=>'Baleric Islands',
    92=>'Bulgaria',
    1=>'Canary Islands',
    21=>'Cyprus',
    96=>'Greece',
    106=>'Malta',
    4=>'Portugal',
    108=>'Spain',
    117=>'Tunisia',
    118=>'Turkey',
);
$l2 = array(
    12=>'Ibiza',
    13=>'Majorca',
    14=>'Menorca',
    10=>'Fuerteventura',
    466=>'Gran Canaria',
    35=>'Lanzarote',
    15=>'Tenerife',
    97=>'Corfu',
    98=>'Crete',
    99=>'Kos',
    100=>'Mykonos',
    101=>'Rhodes',
    102=>'Santorini',
    103=>'Skiathos',
    104=>'Zakynthos',
    19=>'Algarve',
    17=>'Lisbon Coast',
    18=>'Madeira',
    109=>'Costa Blanca',
    110=>'Costa Brava',
    112=>'Costa de Almeira',
    115=>'Costa del Sol',
    116=>'Costa Dorada',
);
$sqltpl = 'update supplier_locations_low set tree_id=%d where country="%s";';
foreach ($l1 as $id=>$c) {
    $sql = sprintf($sqltpl, $id, $c);
    $result = mysql_query($sql) or die (mysql_error());
    print_r($result);
}
$sqltpl = 'update supplier_locations_low set tree_id=%d where region="%s";';
foreach ($l2 as $id=>$c) {
    $sql = sprintf($sqltpl, $id, $c);
    $result = mysql_query($sql) or die (mysql_error());
    print_r($result);
}